﻿using System;
using System.Collections.Generic;
using System.Linq;
using Citi.Scheduler.Domain;

namespace Citi.Scheduler.WebUi.Models
{
    public class RoutineErrorModel: ModelBase<RoutineErrorModel, RoutineError>
    {
        public string ErrorDescription { get; set; }
        public DateTime OcurredOn { get; set; }
        public RoutineErrorStatus Status { get { return RoutineErrorHistories.Last().Status; } }
        public int RoutineExecutionId { get; set; }
        public int RoutineErrorTypeId { get; set; }

        public List<EscalationModel> NextEscalations
        {
            get
            {
                return new EscalationModel().CreateModel(
                    new Escalation().NextEscalations(new RoutineExecution().SelectById<RoutineExecution>(RoutineExecutionId).RoutineId)).ToList();
            }
        }

        public RoutineErrorTypeModel RoutineErrorType { get; set; }
        public IEnumerable<RoutineErrorEmailModel> RoutineErrorEmails { get; set; }
        public IEnumerable<RoutineErrorHistoryModel> RoutineErrorHistories { get; set; }
    }
}